local UIBase = require("view.UIBase")
local NpcTalkUI = class("NpcTalkUI", UIBase)
local NpcTalkCell = require("view.Npc.NpcTalkCell")

function NpcTalkUI:ctor(callback)
    self._callback = callback
    local resource = {
        path = "Prefabs/View/Npc",
        name = "NpcTalkUI",
        canvas = 2
    }
    self._npcCells = {}
    NpcTalkUI.super.ctor(self, resource)
end

function NpcTalkUI:addNpcTalk(npcId)
    local npcCell = NpcTalkCell.new(self, npcId)
    table.insert(self._npcCells, npcCell)
end

function NpcTalkUI:addMonsterTalk(monsterId)
end

function NpcTalkUI:removeTalkUI(npcId)
    for i = 1, #self._npcCells do
        local cell = self._npcCells[i]
        if cell:getNpcId() == npcId then
            cell:close()
            table.remove(self._npcCells, i)
        end
    end
end

function NpcTalkUI:onClose()
    if self._callback then
        self._callback()
    end
end

function NpcTalkUI:_layoutUI()
end

return NpcTalkUI
